package com.sj.configuration.app;

import java.util.ArrayList;
import java.util.List;

import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.MediaType;
import org.springframework.http.converter.HttpMessageConverter;

import com.alibaba.fastjson.serializer.SerializerFeature;
import com.alibaba.fastjson.support.config.FastJsonConfig;
import com.sj.configuration.json.JFastJsonHttpMessageConverter;

@Configuration
public class AppConfiguration {
	@Bean
	public HttpMessageConverters fastJsonHttpMessageConventers() {
		JFastJsonHttpMessageConverter converter = new JFastJsonHttpMessageConverter();
        FastJsonConfig config = new FastJsonConfig();
        List<MediaType> mediaTypes = new ArrayList<MediaType>();
        mediaTypes.add(MediaType.APPLICATION_JSON_UTF8);
        config.setSerializerFeatures(SerializerFeature.PrettyFormat);
        converter.setSupportedMediaTypes(mediaTypes);
        converter.setFastJsonConfig(config);
        HttpMessageConverter<?> converter1 = converter;
        return new HttpMessageConverters(converter1);
	}
}
